'use strict';
angular
    .module('myApp', [
        'ngRoute',
        'moviecat.directives.auto_Focus',
        'myApp.vmoiveDetail',
        'myApp.vmoiveList',
    ])
    .config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) {
        $locationProvider.hashPrefix('!');
        $routeProvider.otherwise({
            redirectTo: '/in_theaters/1'
        });
    }])
    .constant('moiveConfig', {
        pageSize: 10,
        moiveUrl: 'https://api.douban.com/v2/movie/',
        moiveSearchUrl: 'https://api.douban.com/v2/movie/',
        detailUlr: 'https://api.douban.com/v2/movie/subject/'
    })
    .controller('searchCtrl', [
        '$scope',
        '$route',
        function($scope, $route) {
            $scope.input = '';
            $scope.search = function() {
                $route.updateParams({ q: $scope.input, type: 'search' })
            }
        }
    ])
    // .controller('mainCtrl', [
    //     '$scope',
    //     '$location',
    //     'moiveConfig',
    //     function($scope, $location, moiveConfig) {
    //         $scope.$location = $location;
    //         $scope.$watch('$location.path()', function(now, old) {
    //             let p = now.split('/')[1];
    //             switch (p) {
    //                 case 'top250':
    //                     $scope.path = 'top250'
    //                     break;
    //                 case 'coming_soon':
    //                     $scope.path = 'coming_soon'
    //                     break;
    //                 default:
    //                     $scope.path = 'in_theaters';
    //                     break;
    //             }
    //         })
    //     }
    // ])